<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
// use Illuminate\Support\Facades\DB;
class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        // 先执行了构造函数，通过用户验证才可以访问index方法
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $project = Auth::user()->projects()->get();
        // compact 创建一个包含变量名和它们的值的数组
        return view('home',compact('project'));
    }
}
